<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
    <p>替换"microsoft"为"runoob":</p>
    <button onclick="myFunction()">点我</button>
    <p id="demo">visit microsoft!</p>
    <script>
        function myFunction()
        {
            var str=document.getElementById("demo").innerHTML;
            var txt=str.replace(/microsoft/i,"runoob");
            document.getElementById("demo").innerHTML=txt;
        }
        </script>
        </body>
</html>